import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
 * The main of the application. It makes a new serversocket for
 * clients to connect too. It passes the clien to the server object 
 * and puts it in a thread in the threadpool
 * @author Marco Vellinga
 * @author Sander Wagenaar
 *
 */
public class serverMain {
	
	private static ServerSocket serversocket;

	public static void main(String[] args) throws IOException{
		
		// Variable
		serversocket = new ServerSocket(7789);
		
		while (true) {
			// accept connection from the client
			Socket clientSocket = serversocket.accept();
			// Setup the server actions with the connected client.
			Server server = new Server(clientSocket);
			// create the thread with the server for the client
			ExecutorService pool = Executors.newCachedThreadPool();
			pool.execute(server);
		}
	}
}
